<?php
/**
 * 枚举变量定义基类
 */

class EnumBase
{
    protected $_val = '';

    public function __construct($const)
    {
        $refc = new ReflectionClass(get_called_class());
        $const_range = $refc->getConstants();
        $is_in_range = in_array($const, $const_range);
        if ( !$is_in_range )
        {
            throw new Exception('error');
        }
        $this->_val = $const;
    }

    public function __toString()
    {
        return $this->_val;
    }
}